package com.aree.caipiao.shsq.dao.hibernate;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;

import com.aree.caipiao.dao.hibernate.GenericDao;
import com.aree.caipiao.shsq.dao.IShuangSeQiuResultDao;
import com.aree.caipiao.shsq.model.ShuangSeQiuResult;

/**
 * @author hp-pc
 *
 */
/*@Repository("ShuangSeQiuResultHibernateDao")*/
public class ShuangSeQiuResultDao extends GenericDao<ShuangSeQiuResult, Long> implements IShuangSeQiuResultDao {

	/* (non-Javadoc)
	 * @see com.aree.caipiao.shsq.dao.IShuangSeQiuResultDao#getById(java.lang.Long)
	 */
	public ShuangSeQiuResult getById(Long id) {
		return super.get(id);
	}

	/* (non-Javadoc)
	 * @see com.aree.caipiao.shsq.dao.IShuangSeQiuResultDao#getBySerial(java.lang.String)
	 */
	public ShuangSeQiuResult getBySerial(String serial) {
		String hql = "from ShuangSeQiuResult where serial = ?";
		List<ShuangSeQiuResult> result = super.find(hql, serial);
		if (result == null || result.size() == 0) return null;
		return result.get(0);
	}
	
	/* (non-Javadoc)
	 * @see com.aree.caipiao.shsq.dao.IShuangSeQiuResultDao#getHezhiTongji()
	 */
	public List<Integer> getHezhiTongji() {
		String sql = "select red1+red2+red3+red4+red5+red6+blue from ShuangSeQiuResult";
		Session session = this.getSession();
		 session.beginTransaction();
		 Query query = session.createQuery(sql);
		 List<?> list = query.list();
		 List<Integer> result = new ArrayList<Integer>();
		 if (list == null || list.size() == 0) return result;
		 for (int i = 0; i < list.size(); i++) {
			 result.add((Integer)list.get(i));
		 }
		 return result;
	}

	/* (non-Javadoc)
	 * @see com.aree.caipiao.shsq.dao.IShuangSeQiuResultDao#saveShuangSeQiuResult(com.aree.caipiao.shsq.model.ShuangSeQiuResult)
	 */
	public void saveShuangSeQiuResult(ShuangSeQiuResult result) {
		super.save(result);
		
	}

	/* (non-Javadoc)
	 * @see com.aree.caipiao.shsq.dao.IShuangSeQiuResultDao#updateShuangSeQiuResult(com.aree.caipiao.shsq.model.ShuangSeQiuResult)
	 */
	public void updateShuangSeQiuResult(ShuangSeQiuResult result) {
		super.update(result);
		
	}

	/* (non-Javadoc)
	 * @see com.aree.caipiao.shsq.dao.IShuangSeQiuResultDao#count()
	 */
	public int count() {
		// TODO Auto-generated method stub
		return 0;
	}

}
